/*
 * @Author: szx
 * @Date: 2022-02-13 12:20:45
 * @LastEditTime: 2022-02-13 12:26:25
 * @Description:
 * @FilePath: \leetcode\1100-1199\1189\1189.js
 */
/**
 * @param {string} text
 * @return {number}
 */
var maxNumberOfBalloons = function (text) {
    const arr = new Array(26).fill(0);
    for (let i = 0; i < text.length; i++) {
        arr[text.charCodeAt(i) - 97]++;
    }
    let res = 0;
    while (true) {
        arr[0] -= 1;
        arr[1] -= 1;
        arr[11] -= 2;
        arr[13] -= 1;
        arr[14] -= 2;
        if (arr[0] < 0 || arr[1] < 0 || arr[11] < 0 || arr[13] < 0 || arr[14] < 0) break;
        else res++;
    }
    return res;
};
console.log(maxNumberOfBalloons('loonbalxballpoon'));
